export enum resultType {
  success = 0, // 接口成功
  lossParam = -1, // 参数错误
  sqlError = -2, // sql错误
  unknown = -99, // 未知错误
}

export interface ResultError {
  code: number;
  data: { [key: string]: unknown };
  message: string;
}

// 错误JSON
export const resultErrorJson = (
  code: number = resultType.unknown,
  message: string = "失败",
  data: { [key: string]: any } = {}
):ResultError => {
  return {
    code: code,
    data: data,
    message: message,
  };
};
// 成功JSON
export const resultSuccessJson = (
  code: number = resultType.success,
  message: string = "成功",
  data: { [key: string]: any } = {}
) => {
  return {
    code: code,
    data: data,
    message: message,
  };
};
